// System Unit
// Int64 Support

(*************)
(* Interface *)
(*************)
{$IFDEF Include_Modules_Header}

 Function _Round(Val: Extended): Int64;
 Type RTLProc_Round = Function(Val: Extended): Int64;

 Function _Trunc(Val: Extended): Int64;
 Type RTLProc_Trunc = Function(Val: Extended): Int64;

 Procedure __llmul;
 Type RTLProc__llmul = Function(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64; // Param 1 (EAX:EDX)

 Procedure __lldiv;
 Type RTLProc__lldiv = Function(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64; // Param 1 (EAX:EDX)

 Procedure __llmod;
 Type RTLProc__llmod = Function(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64; // Param 1 (EAX:EDX)

 Procedure __llmulo;
 Type RTLProc__llmulo = Function(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64; // Param 1 (EAX:EDX) Overflow signaled in flag register

 Procedure __lldivo;
 Type RTLProc__lldivo = Function(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64; // Param 1 (EAX:EDX) Overflow signaled in flag register

 Procedure __llmodo;
 Type RTLProc__llmodo = Function(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64; // Param 1 (EAX:EDX) Overflow signaled in flag register

 Procedure __lludiv;
 Type RTLProc__lludiv = Function(Param1Hi, Param1Lo: Cardinal; Param2: UInt64): UInt64; // Param 1 (EAX:EDX)

 Procedure __llumod;
 Type RTLProc__llumod = Function(Param1Hi, Param1Lo: Cardinal; Param2: UInt64): UInt64; // Param 1 (EAX:EDX)

 Procedure __llshl;
 Type RTLProc__llshl = Function(Param1Hi, Param1Lo: Integer; Count: Int64): Int64; // Param 1 (EAX:EDX)

 Procedure __llshr;
 Type RTLProc__llshr = Function(Param1Hi, Param1Lo: Integer; Count: Int64): Int64; // Param 1 (EAX:EDX)

 Procedure __llushr;
 Type RTLProc__llushr = Function(Param1Hi, Param1Lo: Cardinal; Count: UInt64): UInt64; // Param 1 (EAX:EDX)

 //==================
 // RTL Extensions
 //==================
 Type
  TRTLEx_Int64 = Record
   _Round: RTLProc_Round;
   _Trunc: RTLProc_Trunc;
   __llmul: RTLProc__llmul;
   __lldiv: RTLProc__lldiv;
   __llmod: RTLProc__llmod;
   __llmulo: RTLProc__llmulo;
   __lldivo: RTLProc__lldivo;
   __llmodo: RTLProc__llmodo;
   __lludiv: RTLProc__lludiv;
   __llumod: RTLProc__llumod;
   __llshl: RTLProc__llshl;
   __llshr: RTLProc__llshr;
   __llushr: RTLProc__llushr;
  END;

 Procedure RTLExtend_Int64(Var Ex: TRTLEx_Int64);

{$ENDIF Include_Modules_Header}
(******************)
(* Implementation *)
(******************)
{$IFDEF Include_Modules_Implement}

 Function _RTL_Round(Val: Extended): Int64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_Trunc(Val: Extended): Int64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL__llmul(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL__lldiv(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL__llmod(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL__llmulo(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL__lldivo(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL__llmodo(Param1Hi, Param1Lo: Integer; Param2: Int64): Int64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL__lludiv(Param1Hi, Param1Lo: Cardinal; Param2: UInt64): UInt64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL__llumod(Param1Hi, Param1Lo: Cardinal; Param2: UInt64): UInt64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL__llshl(Param1Hi, Param1Lo: Integer; Count: Int64): Int64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL__llshr(Param1Hi, Param1Lo: Integer; Count: Int64): Int64;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL__llushr(Param1Hi, Param1Lo: Cardinal; Count: UInt64): UInt64;
  ASM
   JMP _INT_NotImplemented
  END;

 Var
   RTL_Round: RTLProc_Round = _RTL_Round;
   RTL_Trunc: RTLProc_Trunc = _RTL_Trunc;
   RTL__llmul: Pointer = @_RTL__llmul;
   RTL__lldiv: Pointer = @_RTL__lldiv;
   RTL__llmod: Pointer = @_RTL__llmod;
   RTL__llmulo: Pointer = @_RTL__llmulo;
   RTL__lldivo: Pointer = @_RTL__lldivo;
   RTL__llmodo: Pointer = @_RTL__llmodo;
   RTL__lludiv: Pointer = @_RTL__lludiv;
   RTL__llumod: Pointer = @_RTL__llumod;
   RTL__llshl: Pointer = @_RTL__llshl;
   RTL__llshr: Pointer = @_RTL__llshr;
   RTL__llushr: Pointer = @_RTL__llushr;

 Function _Round(Val: Extended): Int64;
  ASM
   JMP RTL_Round
  END;

 Function _Trunc(Val: Extended): Int64;
  ASM
   JMP RTL_Trunc
  END;

 Procedure __llmul;
  ASM
   JMP RTL__llmul
  END;

 Procedure __lldiv;
  ASM
   JMP RTL__lldiv
  END;

 Procedure __llmod;
  ASM
   JMP RTL__llmod
  END;

 Procedure __llmulo;
  ASM
   JMP RTL__llmulo
  END;

 Procedure __lldivo;
  ASM
   JMP RTL__lldivo
  END;

 Procedure __llmodo;
  ASM
   JMP RTL__llmodo
  END;

 Procedure __lludiv;
  ASM
   JMP RTL__lludiv
  END;

 Procedure __llumod;
  ASM
   JMP RTL__llumod
  END;

 Procedure __llshl;
  ASM
   JMP RTL__llshl
  END;

 Procedure __llshr;
  ASM
   JMP RTL__llshr
  END;

 Procedure __llushr;
  ASM
   JMP RTL__llushr
  END;

 //==================
 // RTL Extensions
 //==================

 Procedure RTLExtend_Int64(Var Ex: TRTLEx_Int64);
  BEGIN
   _INT_RTL_DoEx(@RTL_Round, @Ex._Round);
   _INT_RTL_DoEx(@RTL_Trunc, @Ex._Trunc);
   _INT_RTL_DoEx(RTL__llmul, @Ex.__llmul);
   _INT_RTL_DoEx(RTL__lldiv, @Ex.__lldiv);
   _INT_RTL_DoEx(RTL__llmod, @Ex.__llmod);
   _INT_RTL_DoEx(RTL__llmulo, @Ex.__llmulo);
   _INT_RTL_DoEx(RTL__lldivo, @Ex.__lldivo);
   _INT_RTL_DoEx(RTL__llmodo, @Ex.__llmodo);
   _INT_RTL_DoEx(RTL__lludiv, @Ex.__lludiv);
   _INT_RTL_DoEx(RTL__llumod, @Ex.__llumod);
   _INT_RTL_DoEx(RTL__llshl, @Ex.__llshl);
   _INT_RTL_DoEx(RTL__llshr, @Ex.__llshr);
   _INT_RTL_DoEx(RTL__llushr, @Ex.__llushr);
  END;

{$ENDIF Include_Modules_Implement}
(******************)
(* Initialization *)
(******************)
{$IFDEF Include_Modules_Initialize}
{$ENDIF Include_Modules_Initialize}
(****************)
(* Finalization *)
(****************)
{$IFDEF Include_Modules_Finalize}
{$ENDIF Include_Modules_Finalize}
